package cn.codeartist.springboot.component.http.exception;

import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;

import java.net.URI;

/**
 * 调用HTTP接口异常
 *
 * @author 艾江南
 * @date 2019/4/1
 */
@Setter
@Getter
public class HttpException extends RuntimeException {
    /**
     * HTTP请求状态
     */
    private HttpStatus status;
    /**
     * 请求接口URL
     */
    private URI url;
    /**
     * 请求参数
     */
    private Object param;

    public HttpException() {
        super();
    }

    public HttpException(String message) {
        super(message);
    }

    public HttpException(String message, Throwable cause) {
        super(message, cause);
    }

    public HttpException(Throwable cause) {
        super(cause);
    }

    protected HttpException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public HttpException(HttpStatus status, URI url, Object param, Throwable cause) {
        super(cause.getMessage(), cause);
        this.status = status;
        this.url = url;
        this.param = param;
    }
}
